package com.elias.share.utils;

import com.elias.share.enums.WebResultEnum;
import com.elias.share.vo.WebResultVo;

public class WebResultUtil {

    private WebResultUtil() {
    }

    public static <T> WebResultVo<T> success() {
        return WebResultVo.<T>builder()
                .code(WebResultEnum.SUCCESS.getCode())
                .message(WebResultEnum.SUCCESS.getMessage())
                .build();
    }

    public static <T> WebResultVo<T> success(T data) {
        return WebResultVo.<T>builder()
                .code(WebResultEnum.SUCCESS.getCode())
                .message(WebResultEnum.SUCCESS.getMessage())
                .data(data)
                .build();
    }

    public static <T> WebResultVo<T> fail() {
        return WebResultVo.<T>builder()
                .code(WebResultEnum.FAIL.getCode())
                .message(WebResultEnum.FAIL.getMessage())
                .build();
    }

    public static <T> WebResultVo<T> fail(String message) {
        return WebResultVo.<T>builder()
                .code(WebResultEnum.FAIL.getCode())
                .message(message)
                .build();
    }


    public static <T> WebResultVo<T> error(String message) {
        return WebResultVo.<T>builder()
                .code(WebResultEnum.ERROR.getCode())
                .message(message)
                .build();
    }
}
